<%-- 
    Document   : index
    Created on : 21-feb-2012, 21.15.24
    Author     : Domenico
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Magig Soap</title>

        <link href="css/magicsoap.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
        <div id="mainContainer" class="container">
            <div id="header" class="container">
                <div id="headercontainer">
                    <a href="index.jsp"><img src="img/logo.png" id = "logo" alt="Magic Soap Logo" width="80" height="80" /></a>
                </div>
                <div id="widgetBar">[ cart ] [ language ] [ login ]
                </div>
                <span id="title">Magic Soap</span>
            </div>
            <div id="mainColumn">        
                <div id="leftColumn" class="container"><div class="columnTitle">Categories</div>
                    <sql:query var="catResult" dataSource="jdbc/magicsoap">SELECT * FROM category;</sql:query>
                    <c:forEach var="category" items="${catResult.rows}" varStatus="iter">
                        
                        <c:choose>
                            <c:when test="${pageContext.request.queryString == category.idCategory}">
                                <div class="productCategory">${category.description}</div>
                            </c:when>
                            <c:otherwise>
                                <a href="product?${category.idCategory}" class="productCategoryLink">${category.description}</a>
                            </c:otherwise>
                        </c:choose>
                        
                        
                    </c:forEach>
                              
                </div>
                <div id="rightColumn" class="container"><div class="columnTitle">Products</div><sql:query var="result" dataSource="jdbc/magicsoap">SELECT * FROM product WHERE idcategory = ${pageContext.request.queryString};</sql:query>



                    <c:forEach var="product" items="${result.rows}" varStatus="iter">
                        <table id="productList">
                            <tr class="${((iter.index % 2) == 0) ? 'lightRow' : 'darkRow'}">
                                <td>
                                    <img src="${initParam.productImgPath}${product.name}.jpg" alt="${product.name}"/>
                                </td>
                                <td>
                                    <span>${product.description}</span>
                                </td>
                                <td>&euro; ${product.price}</td>
                                <td><form action="addToCart" method="POST">
                                        <input type="hidden" name="productID" value="${product.idproduct}"/>
                                        <input type="submit" value="Add to Cart"/>
                                    </form></td>

                            </tr>
                        </table>
                        <hr></hr>
                    </c:forEach>



                </div>
            </div>
            <div id="footer" class="container">Content for  id "footer" Goes Here</div>
        </div>
    </body>
</html>

